using UnityEngine;
using System.Collections;

public class _2Freezer : MonoBehaviour {

	public Vector2 size;
	
	Vector2 realS;
	
	void Start () {
		
		gameObject.AddComponent("MeshRenderer");
		gameObject.AddComponent("MeshFilter");
		gameObject.AddComponent("BoxCollider");
		
		realS = new Vector2(size.x * Menu.ns.x , size.y * Menu.ns.y);
		
		this.gameObject.transform.position = new Vector3 (transform.position.x * Menu.ns.x , realS.y , 0);

		Mesh mesh = Quad.Create(realS.x ,realS.y );
		gameObject.GetComponent<MeshFilter>().mesh = mesh;
		gameObject.GetComponent<MeshRenderer>().material = (Material) Resources.Load("Outros/Transparent");
		gameObject.GetComponent<MeshRenderer>().material.mainTexture = (Texture) Resources.Load("Texturas/2Freezer");
		gameObject.GetComponent<BoxCollider>().size = new Vector3(realS.x * 2 , realS.y  * 2 , 1);

	}
	
	void Update () 
	{
		transform.Translate(_Speed.speed,0,0);
		
		if(transform.position.x < -40)
		{
			Destroy (gameObject);
		}		
	}
	
	void OnCollisionEnter (Collision c)
	{
		if(c.gameObject.CompareTag("Player"))
		{
			_Player.f_basejump = 0;
		}
	}
}
